﻿namespace FiftyOne.Foundation.Mobile.Detection.Wurfl.Handlers
{
    using FiftyOne.Foundation.Mobile.Detection.Wurfl;
    using System;

    internal class SoftBankHandler : RegexSegmentHandler
    {
        private const string DEFAULT_DEVICE = "softbank_generic";
        private static readonly string PATTERN = @"(SoftBank|Vodafone|J-PHONE)\/\d\.\d\/\w+";

        internal SoftBankHandler() : base(PATTERN)
        {
        }

        protected internal override bool CanHandle(string userAgent)
        {
            return ((userAgent.StartsWith("SoftBank") || userAgent.StartsWith("Vodafone")) || userAgent.StartsWith("J-PHONE"));
        }

        internal override DeviceInfo DefaultDevice
        {
            get
            {
                DeviceInfo deviceInfoFromID = Provider.Instance.GetDeviceInfoFromID("softbank_generic");
                if (deviceInfoFromID != null)
                {
                    return deviceInfoFromID;
                }
                return base.DefaultDevice;
            }
        }
    }
}

